package cn.itcast.web.servlet;

import cn.itcast.daomain.user;
import cn.itcast.service.UserService;
import cn.itcast.service.impl.UserServiceImpl;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet("/UpdateUserServlet")
public class UpdateUserServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        HttpSession session=request.getSession();
        String phone=request.getParameter("phone");
        String id=request.getParameter("id");
        UserService service=new UserServiceImpl();
        int num= service.updateshou(id,phone);
        if (num>0){
            request.setAttribute("codeMi","true");
            request.getRequestDispatcher("/gouwuche.jsp").forward(request,response);
        }else {
            session.setAttribute("codeMi","false");
            request.getRequestDispatcher("/gouwuche.jsp").forward(request,response);
        }
    }
}
